Ext.onReady(function(){
	var tabPanel = new Ext.TabPanel({
        activeTab: 0,
        region: 'center',
        id:'tab_id',
        defaults:{autoScroll: true},
        items:[{
                title: '欢迎',
                autoLoad:{url:'ext3.4Demo/index/Log.jsp',scripts:true}
     	}]
    }); 
	
    treePanel.on('click', function(node, e){
         if(node.isLeaf()){
            e.stopEvent();
            openTab(node);
         }
    });
    
    // 打开一个新的标签
    function openTab(node){
    	var id = 'tab_' + node.attributes.id;
    	var tab = tabPanel.getComponent(id);
        if(tab){
            tabPanel.setActiveTab(tab);
        }else{
           	var newTab = tabPanel.add(new Ext.Panel({
           		closable:true,
                id: 'tab_' + node.attributes.id,
                title:node.attributes.text,
                html: '<iframe src='+ node.attributes.href +' frameborder="0" width="100%" height="100%"></iframe>'
                //autoLoad:{url:node.attributes.href,scripts:true}
            }));
            tabPanel.setActiveTab(newTab);
        }
    }
    
    // 主页面
  	var viewport = new Ext.Viewport({
      	layout: 'border',
      	items: [
	      	new Ext.BoxComponent({
	          	region: 'north',
	          	height: 32, 
	          	autoEl: {
	              	tag: 'div',
	              	html:'<center><h4 style="font-size:30px;">Ext3.4 Demo</h4></center>'
	          	}
      		}),
      		treePanel,
      		tabPanel
      	]
  	});  
});